/** @file Model.h
    @class Model
    @brief The Model contains all gameobjects in a state
*/
#include "stdafx.h"
#include "GameObject.h"
#include "PlayerAvatar.h"
#include <map>
#include "OgreSceneManager.h"

#ifndef __Model_h_
#define __Model_h_

class Model {
public:
	/**
	* @brief Constructor, needs a sceneManager to add objects to Ogre renderer
	*/
	Model(Ogre::SceneManager* sceneManager);
	
	/**
	* @brief Destructor
	*/
	~Model();
	
	/**
	* @brief Update (called each frame)
	*
	* Cleans out objects to be removed, and calls UpdateLogic for all GameObjects.
	*/
	void update(float deltaTime);
	
	/**
	* @brief Get a GameObject by its ID.
	*/
	GameObject* getByID(unsigned int id);
	
	/**
	* @brief Add a new gameobject to the model, at the specified position with the specified ID.
	*/
	void addGameObject(GameObject* gameObject, unsigned int id, float x = 0, float y = 0, float z = 0);
	
	/**
	* @brief Get next unused ID number.
	*/
	unsigned int getNextID();
	
	/**
	* @brief Get all Gameobjects in a Map.
	*/
	std::map<unsigned int, GameObject*>* getGoMap();
	
	/**
	* @brief Attach the camera to a gameObject.
	*/
	bool attachCamera(GameObject* obj);
	
	/**
	* @brief Attach a specific camera to a Gameobject.
	*/
	bool attachCamera(GameObject* obj, Ogre::Camera* cam);
	
	/**
	* @brief Get the Object that has the camera.
	*/
	GameObject* getCameraGameObject();
	
	/**
	* @brief Get the next PlayerAvatar.
	*/
	PlayerAvatar* getNextPlayerAvatar();
	
	/**
	* @brief Get a playerAvatar by its ID.
	*/
	PlayerAvatar* getPlayerAvatarByID(unsigned int id);
	
	/**
	* @brief Get the position of the camera.
	*/
	Ogre::Vector3 getCameraPosition();
	
	/**
	* @brief Get the orientation of the camera.
	*/
	Ogre::Quaternion getCameraOrientation();

private:
	/**
	* @brief Map of all gameobjects.
	*/
	std::map<unsigned int, GameObject*>* m_goMap;
	
	/**
	* @brief List of all player avatars in the game.
	*/
	std::list<PlayerAvatar*> m_playerAvatars;

	//std::list<GameObject*> m_allGameObjects; //unused, removed, kept for reference

	/**
	* @brief Next unused ID.
	*/
	unsigned int m_nextID;

	/**
	* @brief The scene manager for the scene.
	*/
	Ogre::SceneManager* m_sceneMgr;
	/**
	* @brief The gameobject that has the camera object attached to it.
	*/
	GameObject* m_haveCamera;

};

#endif //__Model_h_